﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Nxg.Blog.Core.ViewProjections.Home {
    public class TagDetailViewProjection : IViewProjection<string, Documents.Tag> {
        private readonly DataContext _db;
        public TagDetailViewProjection (DataContext db) {
            _db = db;
        }

        public Documents.Tag Project (string input) {
            return _db.Tag.FirstOrDefault (x => x.Slug == input);
        }
    }

    public class TagsViewProjection : IViewProjection<IEnumerable<string>, IEnumerable<Documents.Tag>> {
        private readonly DataContext _db;

        public TagsViewProjection (DataContext db) {
            _db = db;
        }

        public IEnumerable<Documents.Tag> Project (IEnumerable<string> input) {
            return _db.Tag.Where (x => input.Contains (x.Slug)).ToList ();
        }
    }
}